<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>y Statement (or Seed Statement)</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="ScoregensTop.html" title="Score Statements and GEN Routines" />
    <link rel="prev" href="x.html" title="x Statement" />
    <link rel="next" href="leftbrace.html" title="{ Statement" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">y Statement (or Seed Statement)</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="x.html">Prev</a> </td>
          <th width="60%" align="center">Score Statements and GEN Routines</th>
          <td width="20%" align="right"> <a accesskey="n" href="leftbrace.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="y"></a>
      <div class="titlepage"></div>
      <a id="IndexYStatement" class="indexterm"></a>
      <a id="IndexSeedStatement" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">y Statement (or Seed Statement)</span>
        </h2>
        <p>a — 
      Set seed for random numbers.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp213040720"></a>
        <h2>Description</h2>
        <p>
      Set seed for random numbers, either from p1 or, if omitted, the clock.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp213042000"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>y</strong></span> [p1]</pre>
      </div>
      <div class="refsect1">
        <a id="idp213044016"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>p1</em></span> -- An integer value between 0 and 2<sup>32</sup>
      used as a new seed for random numbers. If omitted, the system clock value will be used instead.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp213046144"></a>
        <h2>Performance</h2>
        <p>
      The tilde symbol ˜ can be used in an expression wherever a number is permissible
      to use. Each ˜ will evaluate to a random value between zero (0) and one (1).
      If there is no y statement in the score, the pseudo-random generator will yield
      the same numbers in each performance. If a fixed seed is given, a different
      predictable series of pseudo-random numbers will be generated from this seed.
      If a y statement is used without p1, the system clock will be used as a seed,
      yielding a different series of pseudo-random numbers for each performance.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp213048000"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the y statement. It uses the file <a class="ulink" href="examples/y_statement.csd" target="_top"><em class="citetitle">y_statement.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp213049792"></a>
          <p class="title">
            <strong>Example 1087. Example of the y statement.</strong>
          </p>
          <div class="example-contents">
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
<span class="comment">; Audio out   Audio in    No messages</span>
-odac           -iadc     -d     <span class="comment">;;;RT audio I/O</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o 0dbfs.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="comment">; Initialize the global variables.</span>
<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 10
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span> <span class="op">=</span> 1

<span class="oblock">instr</span> 1
  <span class="opc">print</span> p4
<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="stamnt">y</span>

<span class="stamnt">i</span> 1 0 1 [~ * 10 + 1]
<span class="stamnt">i</span> 1 + 1 [~ * 10 + 1]
<span class="stamnt">i</span> 1 + 1 [~ * 10 + 1]
<span class="stamnt">i</span> 1 + 1 [~ * 10 + 1]
<span class="stamnt">e</span>

<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
      Each time this example is run, different values between 1 and 10 will be displayed.
      The seed used will be displayed as well.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp213051872"></a>
        <h2>Credits</h2>
        <p>Author: John ffitch, 2014</p>
        <p>New in version 6.03</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="x.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="ScoregensTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="leftbrace.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">x Statement </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> { Statement</td>
        </tr>
      </table>
    </div>
  </body>
</html>
